package com.woniuxy.light_smart.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.light_smart.dto.PollingDto;
import com.woniuxy.light_smart.service.InspectionService;
import com.woniuxy.light_smart.util.Result;
import com.woniuxy.light_smart.vo.PollingVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ：fengsir
 * @date ：Created in 2022/12/6 20:08
 * @description：
 * @modified By：
 * @version: $
 */
@RestController
@RequestMapping("/inspction")
public class InspectionController {
    @Resource
    private InspectionService inspectionService;
    //此方法为查所有
    @GetMapping("")
    public Result sellAll(){
       List<PollingVo> pollingVo= inspectionService.selectAll();
       return Result.ok().data("list",pollingVo);
    }
    //此方法模糊查询
    @PostMapping("query")
    public Result queryByLike(@RequestBody PollingDto pollingDto){
        List<PollingVo> pollingDtos = inspectionService.selectByLike(pollingDto);
        //得到pageInfo的目的就是为了统计一共有多少条数据
        PageInfo<PollingVo> pageInfo = new PageInfo<>(pollingDtos);
        return Result.ok().data("query",pollingDtos).data("total",pageInfo.getTotal());
    }
}
